public class Home {
    public int size;// 大小
    public String type;//
    public String address;
    public int index;// 用来记录索引位置
    Gear[] gears = new Gear[100];// 所有家具放在这里面

    public Home(int s, String t, String a) {
        size = s;
        type = t;
        address = a;
    }

    // 装修
    public void zhuang(Gear gear) {
        if (index < 100) {// 防止数组越界
            if (size < gear.size) {
                System.out.println("面积不够了");
            } else {
                gears[index++] = gear;
                size -= gear.size;//减去家具的面积
                System.out.println("装修成功");
            }

        } else {
            System.out.println("个数满了");
        }
    }
    // 家输出一下有什么家具

    public void introduce() {
//        for (int i = 0; i < index; i++) {
//            System.out.println("装修了" + gears[i].name);
//        }
        int sum = 0;
        for (Gear gear : gears) {
            if (gear != null) {
                sum += gear.size;// sum = sum+gear.size
                System.out.println("装修了" + gear.name);
            } else {
                break;
            }

        }
        System.out.println("一共装修了" + sum + "平剩余" + size + "平");
    }
}
